<template>
  <div class="container">
    <navBar :title="printingJobType" :backStep="'specialWorkIndex'"></navBar>
    <div class="workTitle">作业信息</div>
    <div class="formBox">
      <div class="formItem">
        <van-cell title="作业票编号:">
          <template #default>
            <div>自动生成</div>
          </template>
        </van-cell>
      </div>
      <div class="formItem">
        <van-cell title="作业单位:">
          <template #default>
            <input
              type="text"
              v-model="formInfo.applicantUnit"
              class="inputCss"
              disabled
              placeholder="请输入作业单位"
            />
          </template>
        </van-cell>
        <van-cell title="作业内容:">
          <template #default>
            <input
              type="text"
              v-model="formInfo.fireJobContent"
              class="inputCss"
              placeholder="请输入作业内容"
            />
          </template>
        </van-cell>
        <van-cell title="作业地点:">
          <template #default>
            <input
              type="text"
              v-model="formInfo.firePlace"
              class="inputCss"
              placeholder="请输入作业地点"
            />
          </template>
        </van-cell>

        <van-cell
          v-if="
            ticketTypeCode == 'donghuoanquan' ||
            ticketTypeCode == 'linshiyongdian' ||
            ticketTypeCode == 'dongtuanquan' ||
            ticketTypeCode == 'gaochuanquan'
          "
          title="作业负责人:"
          is-link
          @click="showPicker1 = true"
        >
          <template #default>
            {{ workResponsible }}
          </template>
        </van-cell>
        <van-cell title="作业人:" is-link @click="showPicker = true">
          <template #default>
            {{ worker }}
          </template>
        </van-cell>

        <van-cell title="开始时间:" is-link @click="showTimePicker = true">
          <template #default>
            {{ startTime }}
          </template>
        </van-cell>
        <van-cell title="结束时间:" is-link @click="showTimePicker2 = true">
          <template #default>
            {{ endTime }}
          </template>
        </van-cell>
        <van-cell
          v-if="ticketTypeCode == 'donghuoanquan'"
          title="安全交底人:"
          is-link
          @click="showPicker5 = true"
        >
          <template #default>
            {{ safetyBriefingMan }}
          </template>
        </van-cell>

        <van-cell
          v-if="ticketTypeCode == 'donghuoanquan'"
          title="接受交底人:"
          is-link
          @click="showPicker15 = true"
        >
          <template #default>
            {{ saveSafety }}
          </template>
        </van-cell>
      </div>

      <div class="formItem">
        <van-cell title="作业级别:" is-link @click="showPicker6 = true">
          <template #default>
            {{ workLevel }}
          </template>
        </van-cell>
        <div class="cellCss" v-if="ticketTypeCode == 'donghuoanquan'">
          <div class="cellCssTitle">作业方式:</div>
          <div>
            <van-checkbox-group direction="horizontal" v-model="workMethod">
              <van-checkbox
                shape="square"
                v-for="item in workMethodOptions"
                :key="item.id"
                :name="item.name"
                >{{ item.name }}</van-checkbox
              >
            </van-checkbox-group>
          </div>
        </div>
        <van-cell title="关联作业票:" is-link @click="showPicker7 = true">
          <template #default>
            {{ associatedWork }}
          </template>
        </van-cell>
        <div v-if="ticketTypeCode == 'linshiyongdian'">
          <van-cell title="电源接入点:">
            <template #default>
              <input
                type="text"
                v-model="formInfo.eleInput"
                class="inputCss"
                placeholder="请输入电源接入点"
              />
            </template>
          </van-cell>
          <van-cell title="许可用电功率:">
            <template #default>
              <input
                type="text"
                v-model="formInfo.permittedPower"
                class="inputCss"
                placeholder="请输入许可用电功率"
              />
            </template>
          </van-cell>
          <van-cell title="用电设备名称:">
            <template #default>
              <input
                type="text"
                v-model="formInfo.equipmentName"
                class="inputCss"
                placeholder="请输入用电设备名称"
              />
            </template>
          </van-cell>
          <van-cell title="额定功率:">
            <template #default>
              <input
                type="text"
                v-model="formInfo.ratedPower"
                class="inputCss"
                placeholder="请输入额定功率"
              />
            </template>
          </van-cell>

          <van-cell title="工作电压:">
            <template #default>
              <input
                type="text"
                v-model="formInfo.workingVoltage"
                class="inputCss"
                placeholder="请输入工作电压"
              />
            </template>
          </van-cell>
          <van-cell title="监护人:">
            <template #default>
              <input
                type="text"
                v-model="formInfo.guardian"
                class="inputCss"
                placeholder="请输入监护人"
              />
            </template>
          </van-cell>
          <van-cell title="用电人:">
            <template #default>
              <input
                type="text"
                v-model="formInfo.electricityUser"
                class="inputCss"
                placeholder="请输入用电人"
              />
            </template>
          </van-cell>
        </div>
        <div v-if="ticketTypeCode == 'dongtuanquan'">
          <van-cell title="作业部门:">
            <template #default>
              <input
                type="text"
                v-model="formInfo.workDepartment"
                class="inputCss"
                placeholder="请输入作业部门"
              />
            </template>
          </van-cell>
          <van-cell title="监护人:">
            <template #default>
              <input
                type="text"
                v-model="formInfo.guardian"
                class="inputCss"
                placeholder="请输入监护人"
              />
            </template>
          </van-cell>
        </div>
        <div v-if="ticketTypeCode == 'gaochuanquan'">
          <van-cell title="作业高度(米):">
            <template #default>
              <input
                type="text"
                v-model="formInfo.workHeight"
                class="inputCss"
                placeholder="请输入作业高度(米)"
              />
            </template>
          </van-cell>
          <van-cell title="作业单位:">
            <template #default>
              <input
                type="text"
                v-model="formInfo.workUnit"
                class="inputCss"
                placeholder="请输入作业单位"
              />
            </template>
          </van-cell>
          <van-cell title="监护人:">
            <template #default>
              <input
                type="text"
                v-model="formInfo.guardian"
                class="inputCss"
                placeholder="请输入监护人"
              />
            </template>
          </van-cell>
        </div>

        <div v-if="ticketTypeCode == 'gaochuanquan'">
          <van-cell title="作业部门:">
            <template #default>
              <input
                type="text"
                v-model="formInfo.workDepartment"
                class="inputCss"
                placeholder="请输入作业部门"
              />
            </template>
          </van-cell>
          <van-cell title="吊具名称:">
            <template #default>
              <input
                type="text"
                v-model="formInfo.liftingTool"
                class="inputCss"
                placeholder="请输入吊具名称"
              />
            </template>
          </van-cell>
          <van-cell title="吊物内容:">
            <template #default>
              <input
                type="text"
                v-model="formInfo.liftingContent"
                class="inputCss"
                placeholder="请输入吊物内容"
              />
            </template>
          </van-cell>

          <van-cell title="吊物质量(t):">
            <template #default>
              <input
                type="text"
                v-model="formInfo.liftingWeight"
                class="inputCss"
                placeholder="请输入吊物质量(t)"
              />
            </template>
          </van-cell>
          <van-cell title="指挥人员:">
            <template #default>
              <input
                type="text"
                v-model="formInfo.commander"
                class="inputCss"
                placeholder="请输入指挥人员"
              />
            </template>
          </van-cell>
          <van-cell title="司索人:">
            <template #default>
              <input
                type="text"
                v-model="formInfo.rigger"
                class="inputCss"
                placeholder="请输入司索人"
              />
            </template>
          </van-cell>
          <van-cell title="监护人:">
            <template #default>
              <input
                type="text"
                v-model="formInfo.guardian"
                class="inputCss"
                placeholder="请输入监护人"
              />
            </template>
          </van-cell>
        </div>
        <!-- <div class="cellCss">
          <div class="cellCssTitle">关联图片:</div>
          <div>
            <van-uploader
              v-model="uploader1"
              :max-count="3"
              :after-read="afterRead"
              :before-delete="deleteSubmitPic"
            />
          </div>
        </div> -->
      </div>

      <div class="formItem">
        <div class="cellCss">
          <div class="cellCssTitle">风险辨识结果:</div>
          <div>
            <van-checkbox-group
              direction="horizontal"
              shape="square"
              v-model="check"
            >
              <van-checkbox
                shape="square"
                v-for="item in dangerOptions"
                :key="item.id"
                :name="item.name"
                >{{ item.name }}</van-checkbox
              >
            </van-checkbox-group>
          </div>
        </div>
      </div>

      <div class="workTitle workTitle2">
        分析项目数据
        <div v-show="showAddProject" class="addProject" @click="addProject">
          +新增分析项目
        </div>
      </div>
      <div class="formBox">
        <div v-for="(item, index) in gasAnaList" :key="item.id">
          <div class="formItem">
            <van-cell title="分析项目:" is-link @click="openProject(index)">
              <template #default>
                {{ item.name }}
              </template>
            </van-cell>

            <van-cell title="结果值:">
              <template #default>
                <input
                  type="text"
                  v-model="item.result"
                  class="inputCss"
                  placeholder="请输入结果值"
                />
              </template>
            </van-cell>
            <van-cell
              title="分析时间:"
              is-link
              @click="showTimeAnaPicker = true"
            >
              <template #default>
                {{ item.time }}
              </template>
            </van-cell>
            <van-cell title="分析人:">
              <template #default>
                <input
                  type="text"
                  v-model="item.user"
                  class="inputCss"
                  placeholder="请输入分析人"
                />
              </template>
            </van-cell>
            <div @click="deleteAna(index)" class="deleteDiv" v-show="index > 0">
              <van-icon name="delete-o" />删除
            </div>
          </div>
        </div>
      </div>

      <div class="workTitle">安全措施评估</div>
      <div class="formItem" v-for="item in measureList" :key="item.id">
        <div class="cellCss">
          <div class="cellCssTitle">{{ item.content }}:</div>
          <div class="cellCssContent">
            <div class="left">
              <!-- 确认人：<span style="color: #b2b6bc" @click="chooseName"
                >张三 ></span
              > -->
            </div>
            <div class="right">
              涉及：<van-switch size="25" v-model="item.isture" />
            </div>
          </div>
        </div>
      </div>
    </div>

    <div class="workTitle workTitle2">审批人信息</div>
    <div class="formBox">
      <div class="formItem">
        <van-cell title="作业审批负责人:" is-link @click="showPicker14 = true">
          <template #default>
            {{ workApprove }}
          </template>
        </van-cell>

        <van-cell
          title="安全管理部门意见:"
          is-link
          @click="showPicker10 = true"
        >
          <template #default>
            {{ safetyManagementOpinion }}
          </template>
        </van-cell>
        <van-cell title="审批人意见:" is-link @click="showPicker11 = true">
          <template #default>
            {{ hotWorkApproveOpinion }}
          </template>
        </van-cell>

        <van-cell title="验收人:" is-link @click="showPicker8 = true">
          <template #default>
            {{ workResponsibleOpinion }}
          </template>
        </van-cell>
      </div>
    </div>

    <van-goods-action>
      <van-goods-action-button
        :style="{
          background: '#0077FF',
          color: '#fff',
        }"
        type="danger"
        text="提交"
        @click="onClickButton1"
      />
    </van-goods-action>

    <div>
      <van-popup v-model="showPicker" position="bottom">
        <van-picker
          title="作业人"
          show-toolbar
          :columns="options3"
          @confirm="onConfirm"
          @cancel="showPicker = false"
        />
      </van-popup>
      <van-popup v-model="showPicker1" position="bottom">
        <van-picker
          title="作业负责人"
          show-toolbar
          :columns="options"
          @confirm="onConfirm1"
          @cancel="showPicker1 = false"
        />
      </van-popup>
      <van-popup v-model="showTimePicker" position="bottom">
        <van-datetime-picker
          v-model="currentDate"
          type="datetime"
          title="选择开始时间"
          :min-date="minDate"
          :max-date="maxDate"
          @confirm="confirmDate"
          @cancel="cancelShowTimePicker"
        />
      </van-popup>
      <van-popup v-model="showTimePicker2" position="bottom">
        <van-datetime-picker
          v-model="currentDate2"
          type="datetime"
          title="选择结束时间"
          :min-date="minDate"
          :max-date="maxDate"
          @confirm="confirmDate2"
          @cancel="cancelShowTimePicker2"
        />
      </van-popup>
      <van-popup v-model="showPicker5" position="bottom">
        <van-picker
          title="安全交底人"
          show-toolbar
          :columns="options"
          @confirm="onConfirm5"
          @cancel="showPicker5 = false"
        />
      </van-popup>
    </div>
    <div>
      <van-popup v-model="showPicker6" position="bottom">
        <van-picker
          title="作业级别"
          show-toolbar
          :columns="options1"
          @confirm="onConfirm6"
          @cancel="showPicker6 = false"
        />
      </van-popup>

      <van-popup v-model="showPicker7" position="bottom">
        <van-picker
          title="关联作业票"
          show-toolbar
          :columns="ticketList"
          @confirm="onConfirm7"
          @cancel="showPicker7 = false"
        />
      </van-popup>
    </div>
    <div>
      <van-popup v-model="showPicker8" position="bottom">
        <van-picker
          title="验收人意见"
          show-toolbar
          :columns="options2"
          @confirm="onConfirm8"
          @cancel="showPicker8 = false"
        />
      </van-popup>
      <van-popup v-model="showPicker9" position="bottom">
        <van-picker
          title="所在单位意见"
          show-toolbar
          :columns="options"
          @confirm="onConfirm13"
          @cancel="showPicker9 = false"
        />
      </van-popup>
      <van-popup v-model="showPicker10" position="bottom">
        <van-picker
          title="安全管理部门意见"
          show-toolbar
          :columns="options"
          @confirm="onConfirm14"
          @cancel="showPicker10 = false"
        />
      </van-popup>

      <van-popup v-model="showPicker11" position="bottom">
        <van-picker
          title="审批人意见"
          show-toolbar
          :columns="options"
          @confirm="onConfirm15"
          @cancel="showPicker11 = false"
        />
      </van-popup>

      <van-popup v-model="showPicker12" position="bottom">
        <van-picker
          title="岗位当班班长意见"
          show-toolbar
          :columns="options"
          @confirm="onConfirm16"
          @cancel="showPicker12 = false"
        />
      </van-popup>

      <!-- <van-popup v-model="showPicker13" position="bottom">
        <van-picker
          title="分析人"
          show-toolbar
          :columns="options"
          @confirm="onConfirm17"
          @cancel="showPicker13 = false"
        />
      </van-popup> -->

      <van-popup v-model="showPicker14" position="bottom">
        <van-picker
          title="作业审批负责人"
          show-toolbar
          :columns="options"
          @confirm="onConfirm18"
          @cancel="showPicker14 = false"
        />
      </van-popup>

      <van-popup v-model="showPicker15" position="bottom">
        <van-picker
          title="接受交底人"
          show-toolbar
          :columns="options"
          @confirm="onConfirm19"
          @cancel="showPicker15 = false"
        />
      </van-popup>
      <van-popup v-model="showTimeAnaPicker" position="bottom">
        <van-datetime-picker
          v-model="currentDate"
          type="datetime"
          title="选择分析时间"
          :min-date="minDate"
          :max-date="maxDate"
          @confirm="confirmDate3"
          @cancel="cancelShowTimePicker"
        />
      </van-popup>

      <van-popup v-model="showPickerProject" position="bottom">
        <van-picker
          title="分析项目"
          show-toolbar
          :columns="analyzeOptions"
          @confirm="onConfirmAnaPro"
          @cancel="showPickerProject = false"
        />
      </van-popup>
    </div>
  </div>
</template>

<script>
import {
  riskLevelListApi,
  workModeListApi,
  riskIdentificationListApi,
  securityMeasureListApi,
  analysisItemListApi,
  // workDurationListApi,
  // workInterruptionDurationListApi,
  specialCardListApi,
  approverListApi,
} from '@/api/dictionary.js'
import { getTicketistApi, userListApi, addOrUpdateApi } from '@/api/ticket.js'
import navBar from '@/components/navBar.vue'
import '@/css/form.scss'

export default {
  name: 'applyWork',
  props: {},
  components: {
    navBar,
  },
  data() {
    return {
      formInfo: {
        fireJobContent: '',
        firePlace: '',
        applicantUnit: '',
      },
      worker: '请选择作业人',
      workResponsible: '请选择作业负责人',
      workMonitor: '请选择作业监护人',
      measureMaker: '请选择措施制定人',
      safetyBriefingMan: '请选择安全交底人',
      options: [],
      options1: [],
      options2: [],
      options3: [],
      startTime: '请选择',
      endTime: '请选择',
      currentDate: '',
      currentDate2: '',
      showTimePicker: false,
      showTimePicker2: false,
      showPicker: false,
      showPicker1: false,
      showPicker2: false,
      showPicker5: false,
      showPicker6: false,
      showPicker7: false,
      showPicker8: false,
      showPicker9: false,
      showPicker10: false,
      showPicker11: false,
      showPicker12: false,
      showPicker14: false,
      showPicker15: false,
      minDate: new Date(2024, 0, 1),
      maxDate: new Date(2029, 10, 1),
      workLevel: '请选择作业级别',
      workMethod: [],
      associatedWork: '请选择',
      uploader1: [],
      uploaderSubmit: [],
      workResponsibleOpinion: '请选择',
      unitOpinion: '请选择',
      safetyManagementOpinion: '请选择',
      hotWorkApproveOpinion: '请选择',
      hotMonitorOpinion: '请选择',
      printingJobType: '',
      ticketTypeCode: '',
      workMethodOptions: [],
      ticketList: [],
      analysisOpinion: '请选择分析人',
      workApprove: '请选择',
      saveSafety: '请选择接受交底人',
      check: [],
      dangerOptions: [],
      analyzeTime: '',
      analyser: '',
      analyzeProject: '',
      analyzeStandard: '',
      analyzeResult: '',
      showPickerProject: false,
      measureList: [],
      showTimeAnaPicker: false,
      allOption: [],
      analyzeOptions: [],
      gasAnaList: [
        {
          name: '',
          result: '',
          time: this.getCurrentDateTime(),
          user: '',
        },
      ],
      nowProject: 0,
      showAddProject: true,
      workerId: null,
    }
  },
  created() {
    this.printingJobType = this.$route.query.type
    this.ticketTypeCode = this.$route.query.code
    console.log(this.ticketTypeCode)
    this.getDictionaryList()
    this.isLoginMsg = JSON.parse(sessionStorage.getItem('loginInfo'))
    this.formInfo.applicantUnit = this.isLoginMsg.departmentName
    this.startTime = this.getCurrentDateTime()
    this.endTime = this.getCurrentDateTime()
    this.analyzeTime = this.getCurrentDateTime()
  },
  methods: {
    getCurrentDateTime() {
      const now = new Date()
      return `${now.getFullYear()}-${String(now.getMonth() + 1).padStart(
        2,
        '0'
      )}-${String(now.getDate()).padStart(2, '0')} ${String(
        now.getHours()
      ).padStart(2, '0')}:${String(now.getMinutes()).padStart(2, '0')}:${String(
        now.getSeconds()
      ).padStart(2, '0')}`
    },
    async onClickButton1() {
      const findItem8 = this.options.filter(
        (item) => item.text === this.workResponsible
      )
      const workResponsibleId = findItem8.length > 0 ? findItem8[0].value : ''

      const findItem10 = this.options.filter(
        (item) => item.text === this.workApprove
      )
      const workApproveId = findItem10.length > 0 ? findItem10[0].value : ''
      const findItem5 = this.options.filter(
        (item) => item.text === this.safetyManagementOpinion
      )
      const safetyManagementOpinionId =
        findItem5.length > 0 ? findItem5[0].value : ''

      const findItem6 = this.options.filter(
        (item) => item.text === this.hotWorkApproveOpinion
      )
      const hotWorkApproveOpinionId =
        findItem6.length > 0 ? findItem6[0].value : ''

      const findItem7 = this.options.filter(
        (item) => item.text === this.workResponsibleOpinion
      )
      const workResponsibleOpinionId =
        findItem7.length > 0 ? findItem7[0].value : ''

      const gasList = this.gasAnaList.map((item) => {
        return {
          gasName: item.name,
          analysisTime: item.time,
          analysisResult: item.result,
          analysisUser: item.user,
        }
      })
      const list = this.measureList.map((item) => {
        return {
          name: item.content,
          isInvolved: item.isture == true ? 1 : 0,
        }
      })

      const findItem11 = this.options1.filter(
        (item) => item.text === this.workLevel
      )
      const workLevelId = findItem11.length > 0 ? findItem11[0].value : ''

      const data = {
        ticketTypeCode: this.ticketTypeCode,
        ticketLevelId: workLevelId,
        startTime: this.startTime,
        endTime: this.endTime,
        workPlace: this.formInfo.firePlace,
        workContent: this.formInfo.fireJobContent,
        applyDeptId: this.isLoginMsg.departmentId,
        gasSampleList: gasList, //分析气体
        fireUserList: [
          {
            name: this.worker,
            id: this.workerId,
          },
        ],
        approveUserIdList: JSON.parse(
          JSON.stringify([
            {
              key: workApproveId,
              value: '作业审批负责人',
            },
            {
              key: safetyManagementOpinionId,
              value: '安全管理部门意见',
            },
            {
              key: hotWorkApproveOpinionId,
              value: '审批人意见',
            },
            {
              key: workResponsibleOpinionId,
              value: '验收人',
            },
          ])
        ),
        ticketSecurityMethods: list,
        relateTicketCode: this.associatedWork, //关联作业
        riskResult: this.check.join(), //风险辨识
      }
      // console.log(data)

      const fireWork = {
        fireMethod: this.workMethod.join(), //作业方式
        fireSupervisor: workResponsibleId, //作业负责人
        safeInstructor: this.safetyBriefingMan, //安全交底
        acceptInstructor: this.saveSafety, //接受交底
      }
      const eleWork = {
        powerAccessPoint: this.formInfo.eleInput,
        permittedPower: this.formInfo.permittedPower,
        equipmentName: this.formInfo.equipmentName,
        ratedPower: this.formInfo.ratedPower,
        workingVoltage: this.formInfo.workingVoltage,
        guardian: this.formInfo.guardian,
        electricityUser: this.formInfo.electricityUser,
        workLeader: workResponsibleId, //作业负责人
      }

      const dongtuObj = {
        workDepartment: this.formInfo.workDepartment,
        guardian: this.formInfo.guardian,
        workLeader: workResponsibleId, //作业负责人
      }
      const gaokongObj = {
        workHeight: this.formInfo.workHeight,
        workUnit: this.formInfo.workUnit,
        guardian: this.formInfo.guardian,
        workLeader: workResponsibleId, //作业负责人
      }
      const diaozhuangIbj = {
        workDepartment: this.formInfo.workDepartment,
        liftingTool: this.formInfo.liftingTool,
        liftingContent: this.formInfo.liftingContent,
        liftingWeight: this.formInfo.liftingWeight,
        commander: this.formInfo.commander,
        rigger: this.formInfo.rigger,
        guardian: this.formInfo.guardian,
      }
      const upObj = {
        ...data,
        ticketFireWork:
          this.ticketTypeCode == 'donghuoanquan' ? fireWork : null,
        ticketTemporaryElectric:
          this.ticketTypeCode == 'linshiyongdian' ? eleWork : null,
        ticketExcavation:
          this.ticketTypeCode == 'dongtuanquan' ? dongtuObj : null,
        ticketHeightWork:
          this.ticketTypeCode == 'gaochuanquan' ? gaokongObj : null,
        ticketLifting:
          this.ticketTypeCode == 'diaozhuanganquan' ? diaozhuangIbj : null,
      }

      const res = await addOrUpdateApi({ ...upObj })
      if (res.code == 0) {
        this.$router.push('/applyResult')
      }
    },
    onConfirm(e) {
      this.worker = e.text
      this.workerId = e.value
      this.showPicker = false
    },
    onConfirm1(e) {
      this.workResponsible = e.text
      this.showPicker1 = false
    },
    onConfirmAnaPro(e) {
      const findItem = this.allOption.find((item) => item.name === e)

      this.analyzeProject = findItem.name
      this.gasAnaList[this.nowProject].name = findItem.name

      this.showPickerProject = false
    },
    openProject(index) {
      this.nowProject = index
      this.showPickerProject = true
    },
    onConfirm5(e) {
      this.safetyBriefingMan = e.text
      this.showPicker5 = false
    },
    onConfirm6(e) {
      this.workLevel = e.text
      this.showPicker6 = false
    },
    onConfirm7(e) {
      this.associatedWork = e.text
      this.showPicker7 = false
    },
    onConfirm8(e) {
      this.workResponsibleOpinion = e.text
      this.showPicker8 = false
    },
    onConfirm9(e) {
      this.unitOpinion = e.text
      this.showPicker9 = false
    },
    onConfirm10(e) {
      this.safetyManagementOpinion = e.text
      this.showPicker10 = false
    },
    onConfirm11(e) {
      this.hotWorkApproveOpinion = e.text
      this.showPicker11 = false
    },
    onConfirm12(e) {
      this.hotMonitorOpinion = e.text
      this.showPicker12 = false
    },
    onConfirm13(e) {
      this.unitOpinion = e.text
      this.showPicker9 = false
    },
    onConfirm14(e) {
      this.safetyManagementOpinion = e.text
      this.showPicker10 = false
    },
    onConfirm15(e) {
      this.hotWorkApproveOpinion = e.text
      this.showPicker11 = false
    },
    onConfirm16(e) {
      this.hotMonitorOpinion = e.text
      this.showPicker12 = false
    },
    onConfirm18(e) {
      this.workApprove = e.text
      this.showPicker14 = false
    },
    onConfirm19(e) {
      this.saveSafety = e.text
      this.showPicker15 = false
    },
    formatDate(date) {
      // 获取年、月、日、时、分、秒
      const year = date.getFullYear()
      const month = String(date.getMonth() + 1).padStart(2, '0') // 月份从0开始，需要加1
      const day = String(date.getDate()).padStart(2, '0')
      const hours = String(date.getHours()).padStart(2, '0') // 获取小时
      const minutes = String(date.getMinutes()).padStart(2, '0') // 获取分钟
      const seconds = String(date.getSeconds()).padStart(2, '0') // 获取秒
      // 拼接成目标格式
      return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`
    },
    confirmDate(e) {
      this.startTime = this.formatDate(e)
      this.showTimePicker = false
    },
    cancelShowTimePicker() {
      this.showTimePicker = false
      this.startTime = '请选择'
    },
    confirmDate2(e) {
      this.endTime = this.formatDate(e)
      this.showTimePicker2 = false
    },
    confirmDate3(e) {
      this.analyzeTime = this.formatDate(e)
      this.showTimeAnaPicker = false
    },
    cancelShowTimePicker3() {
      this.showTimeAnaPicker = false
      this.analyzeTime = '请选择'
    },
    cancelShowTimePicker2() {
      this.showTimePicker2 = false
      this.endTime = '请选择'
    },

    // async afterRead(file) {
    //   // 此时可以自行将文件上传至服务器
    //   const formData = new FormData()
    //   formData.append('file', file.file)
    //   this.$toast.loading({
    //     message: '加载中...',
    //     forbidClick: true,
    //     duration: 0,
    //   })
    //   const res = await uploadApi(formData)
    //   // console.log(1);
    //   if (res.code === 0) {
    //     this.uploaderSubmit.push(res.data)
    //   } else {
    //     this.uploader1.pop()
    //     // console.log(this.uploader1)
    //   }
    //   this.$toast.clear()

    //   setTimeout(() => {
    //     this.$toast.clear()
    //   }, 3000)
    // },
    // deleteSubmitPic(e, detail) {
    //   this.uploaderSubmit.splice(detail.index, 1)
    //   this.uploader1.splice(detail.index, 1)
    // },
    async getDictionaryList() {
      const res1 = await riskLevelListApi({
        ticketTypeCode: this.ticketTypeCode,
      })
      this.options1 = res1.data.map((item) => {
        return {
          text: item.name,
          value: item.id,
        }
      })

      const res2 = await workModeListApi({
        ticketTypeCode: this.ticketTypeCode,
      })
      this.workMethodOptions = res2.data

      const res3 = await riskIdentificationListApi({
        ticketTypeCode: this.ticketTypeCode,
      })
      this.dangerOptions = res3.data
      this.check = this.formInfoObj?.analysisDanger?.split(',') || []

      const res4 = await securityMeasureListApi({
        ticketTypeCode: this.ticketTypeCode,
      })
      this.measureList = res4.data.map((item) => {
        return {
          ...item,
          isture: true,
          content: item.name,
        }
      })

      const res5 = await analysisItemListApi({
        ticketTypeCode: this.ticketTypeCode,
      })
      this.allOption = res5.data
      this.analyzeOptions = res5.data.map((item) => item.name)
      const res8 = await getTicketistApi({})
      this.ticketList = res8.data.map((item) => {
        return {
          text: item.printingJobId,
          value: item.printingJobId,
        }
      })

      const res9 = await userListApi({
        name: null,
      })
      this.userList = res9.data
      this.options = res9.data.map((item) => {
        return {
          text: item.name,
          value: item.id,
        }
      })

      const res10 = await approverListApi({
        ticketTypeCode: this.ticketTypeCode,
      })
      this.options2 = res10.data.map((item) => {
        return {
          text: item.name,
          value: item.code,
        }
      })

      const res11 = await specialCardListApi({
        ticketTypeCode: this.ticketTypeCode,
      })
      this.options3 = res11.data.map((item) => {
        return {
          text: item.name,
          value: item.id,
        }
      })
    },
    addProject() {
      if (this.gasAnaList.length >= 3) {
        this.showAddProject = false
        return
      }
      this.gasAnaList.push({
        name: '',
        result: '',
        time: this.getCurrentDateTime(),
        user: '',
      })
    },
    deleteAna(index) {
      this.gasAnaList.splice(index, 1)
    },
  },
  mounted() {},
  watch: {},
  computed: {},
  filters: {},
}
</script>

<style scoped lang="scss">
.container {
  background-color: #f5f6f7;
  width: 100%;
  height: 100%;
  padding: 16px;
  box-sizing: border-box;
  padding-bottom: 60px;
}
.workTitle {
  padding-left: 8px;
  color: #313235;
  font-size: 16px;
  font-weight: bold;
  position: relative;
  margin-bottom: 12px;
  .addProject {
    background-color: #0077ff;
    color: #fff;
    position: absolute;
    width: 120px;
    text-align: center;
    padding: 5px;
    right: 0;
    top: 0;
    height: 25px;
    line-height: 25px;
    transform: translateY(-10px);
    border-radius: 5px;
  }
}
.workTitle2 {
  margin-top: 20px;
}
.workTitle::before {
  content: '';
  position: absolute;
  left: -1px;
  top: 4px;
  border-radius: 2px;
  width: 4px; /* 颜色条的宽度 */
  height: 14px; /* 颜色条的高度 */
  background-color: #0077ff; /* 颜色条的颜色 */
}

.formBox {
  // padding: 16px;
  background: #f7f7f7;
  .formTitle {
    font-weight: bold;
    font-size: 16px;
    color: #2f3133;
    margin-bottom: 16px;
  }
  .formItem {
    border-radius: 10px; /* 设置圆角大小 */
    overflow: hidden; /* 隐藏超出部分 */
    background-color: #fff; /* 可选：设置背景颜色 */
    margin-bottom: 12px;
    .inputCss {
      border: none;
      outline: none;
      background: transparent;
      font-size: 14px;
      text-align: right; /* 添加这行代码 */
    }
    .cellCss {
      box-sizing: border-box;
      width: 100%;
      padding: 10px 16px;
      overflow: hidden;
      color: #323233;
      font-size: 14px;
      line-height: 24px;
      background-color: #fff;
      .cellCssTitle {
        margin-bottom: 10px;
      }
      textarea {
        width: 100%;
        border: none;
      }
      .cellCssContent {
        display: flex;
        align-items: center;
        justify-content: space-between;
        margin: 5px 0;
        .right {
          display: flex;
          align-items: center;
        }
      }
    }
    .deleteDiv {
      padding: 5px 0;
      text-align: center;
      color: #fff;
      background-color: #0077ff;
    }
  }
}

.van-cell {
  align-items: center;
  ::v-deep .van-field__label {
    color: #323233 !important ;
  }
}
.van-cell__value {
  overflow: visible;
}
.van-checkbox--horizontal {
  margin-bottom: 6px;
}
</style>
